﻿using System;
using System.Collections.Generic;
using System.Text;
using Entity;
using System.Data;
using System.Data.SqlClient;
using ECommerce.DAL;

namespace Entity
{
    [System.ComponentModel.DataObject]
    public class TblUserOrderExtended : TblUserOrder
    {
        public static TblUserOrder GetTblUserOrderByOrderId(Int32 OrderId)
        {
            if (OrderId <= GetUserOrderIdMinValue)
                throw (new ArgumentOutOfRangeException("OrderId"));

            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@OrderId", SqlDbType.Int, 0, ParameterDirection.Input, OrderId);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBLUSERORDER_GETTBLUSERORDERBYORDERID);
            GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblUserOrderCollectionFromReader);
            CustomCollection<TblUserOrder> objCollection = ((CustomCollection<TblUserOrder>)ExecuteReaderCmd(sqlCmd, test));

            if (objCollection.Count > 0)
                return objCollection[0];
            else
                return null;
        }
        
        internal const string SP_TBLUSERORDER_GETTBLUSERORDERBYORDERID = "sp_TblUserOrder_GetTblUserOrderByOrderId";
    }
}
